package com.lmb.controller;

import com.lmb.bean.EmergencyEvents;
import com.lmb.mapper.EmergencyEventsDao;
import com.lmb.service.EmergencyEventsService;
import com.lmb.util.Page;
import com.lmb.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/emergencyEvents")
public class EmergencyEventsController {
    @Autowired
    EmergencyEventsDao emergencyEventsDao;
    @Autowired
    EmergencyEventsService emergencyEventsService;
    @PostMapping
    public Result add(@RequestBody EmergencyEvents emergencyEvents)
    {
        Object obj=emergencyEventsService.add(emergencyEvents);
        return Result.success(obj);
    }
    @DeleteMapping("{id}")
    public Result del(@PathVariable("id") Integer id){
        Object obj=emergencyEventsService.del(id);
        return Result.success(obj);
    }
    @PutMapping
    public Result edit(@RequestBody EmergencyEvents emergencyEvents){
        Object obj=emergencyEventsService.edit(emergencyEvents);
        return Result.success(obj);
    }
    @GetMapping("all")
    public Result all( EmergencyEvents emergencyEvents){
        Object obj=emergencyEventsService.all(emergencyEvents);
        return Result.success(obj);
    }
    @GetMapping("{id}")
    public Result one(@PathVariable("id") Integer id){
        Object obj=emergencyEventsService.one(id);
        return Result.success(obj);
    }
    @GetMapping("page")
    public Result page(Page page, EmergencyEvents emergencyEvents){
        emergencyEventsService.page(page,emergencyEvents);
        return Result.success(page);
    }
}
